<?php
require_once(dirname(__FILE__)."/../src/user_mod_check_user_login.php");
require_once(dirname(__FILE__)."/../src/user_mod_insert_user_reg.php");
require_once(dirname(__FILE__)."/../src/user_mod_insert_party_reg.php");
require_once(dirname(__FILE__)."/../src/user_mod_is_username_reg.php");
require_once(dirname(__FILE__)."/../src/user_mod_is_party_emailaccount_reg.php");
require_once(dirname(__FILE__)."/../src/user_mod_check_party_login.php");
require_once(dirname(__FILE__)."/../include/mod_ajax_transfer.php");
require_once(dirname(__FILE__)."/../src/user_mod_get_partyid_by_email.php");

try{
	if($_SERVER['REQUEST_METHOD'] == "POST")
	{
		switch ($_POST['act'])
		{
			case 'ajax_transfer':
				echo ajax_transfer($_POST['serId'], $_POST['serarg']);
				break;
			case 'check_user_login':
				echo check_user_login($_POST['username'], $_POST['password']);
				break;

			case 'insert_user_reg':
				echo insert_user_reg($_POST['email'], $_POST['username'], $_POST['password']);
				break;
			
			case 'insert_party_reg':
				echo insert_party_reg($_POST['email_account'], stripslashes( $_POST['partyname'] ), $_POST['password']);
				break;

			case 'check_party_login':
				echo check_party_login( $_POST['email_account'], $_POST['password'] );
				break;

			default:
				throw new Exception('POST_Serviceurl_Not_Found');
				break;
		}


	}
	else if($_SERVER['REQUEST_METHOD'] == "GET")
	{
		switch ($_GET['act'])
		{

			case 'is_username_reg':
				echo is_username_reg($_GET['username']);
				break;
			
			case 'is_party_emailaccount_reg':
				echo is_party_emailaccount_reg( $_GET['email_account'] );
				break;
			
			case 'get_partyid_by_email':
				echo get_partyid_by_email( $_GET['email_account'] );
			    break;

			default:
				throw new Exception('GET_Serviceurl_Not_Found');
				break;
		}
	}
	else
	{
		throw new Exception('Err_Not_GET_POST_Serviceurl');
	}
}

catch(Exception $e){
  
  date_default_timezone_set('PRC');
  error_log( date("Y-m-d   H:i:s")."   "."line: ".$e->getLine()." in file: ".$e->getFile()." throw exception.\r\n", 3, "./php_exception_catch_log.log");
  error_log( $e->getTraceAsString()."\r\n\r\n", 3, "./php_exception_catch_log.log");

  echo 'serviceurl_unexpected_error';
 }//捕获异常


?>